//
//  OrgNameTableCell.swift
//  test-ios
//
//  Created by wyz5204 on 2023/6/18.
//

import Foundation
import UIKit


class OrgNameTableCell : AbstractTableViewCell<OrgBean> {
    
    private lazy var iconView = {
        return UIImageView().then { view in
            view.layer.cornerRadius = 8
            view.layer.masksToBounds = true
        }
    }()
    
    private lazy var titleLabel = {
        return UILabel().then { view in
            view.font = UIFont.systemFont(ofSize: 15, weight: .regular)
            view.textColor = .rd_title_one
        }
    }()
    
    private lazy var lineView = {
        return UIView().then { view in
            view.backgroundColor = .rd_line
        }
    }()
    
    override func initView() {
        backgroundColor = UIColor.white
        iconView.backgroundColor = UIColor.white
        
        iconView.addTo(self) { view in
            view.snp.makeConstraints { make in
                make.centerY.equalToSuperview()
                make.left.equalToSuperview().offset(15)
                make.width.height.equalTo(30)
            }
        }
        
        titleLabel.addTo(self) { view in
            view.snp.makeConstraints { make in
                make.centerY.equalToSuperview()
                make.left.equalTo(iconView.snp.right).offset(12)
                make.right.equalToSuperview().offset(-15)
            }
        }
        
        lineView.addTo(self) { view in
            view.snp.makeConstraints { make in
                make.right.bottom.equalToSuperview()
                make.left.equalTo(titleLabel.snp.left)
                make.height.equalTo(1)
            }
        }
    }
    
    override var isSelected: Bool {
        didSet {
            titleLabel.textColor = isSelected ? .theme : .black_dark
        }
    }
    
    override func initBinder(_ view: UITableView, _ data: OrgBean, _ index: IndexPath) {
        
        iconView.image = UIImage.init(systemName: "AppIcon")
        titleLabel.text = data.orgName
        //        isSelected = model.m_isSelected
    }
}
